package rm.metrology.shared;

import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;

public enum StatusEnum {

	NEW("NEW"), 
	VOID("VOID"),
	EXPIRED("EXPIRED"),
	WASTED("WASTED"), 
	CALIBRATING("CALIBRATING"),
	CALIBRATED("CALIBRATED"),
	INACCURATE("INACCURATE"),
	PAYING("PAYING"),
	UNPAID("UNPAID"),
	REGISTERED("REGISTERED");
	
	private String fName;
	
	private static List<String> fUnmodifiableEnumNames;
	
	private StatusEnum(String name) {
		fName = name;
	}
	
	@Override
	public String toString() {
		return fName;
	}
	
	public static StatusEnum toEnum(String name) {
		for (StatusEnum t : EnumSet.allOf(StatusEnum.class)) {
			if (t.toString().equalsIgnoreCase(name)) {
				return t;
			}
		}
		throw new IllegalArgumentException("StatusType Invalid: " + name);
	}
	
	public static List<String> toEnumNames() {
		if (fUnmodifiableEnumNames == null) {
			List<String> tmpList = new ArrayList<String>();
			for (StatusEnum t : EnumSet.allOf(StatusEnum.class)) {
				tmpList.add(t.toString());
			}
			fUnmodifiableEnumNames = Collections.unmodifiableList(tmpList);
		}
		return fUnmodifiableEnumNames;
	}
	
}
